package _16并发工具类Semaphore;

import java.util.concurrent.Semaphore;

public class Parking implements Runnable{

    static Semaphore semaphore = new Semaphore(2);

    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        try {
            semaphore.acquire();

            System.out.println(name+"进入停车场了");
            Thread.sleep(3000);
            System.out.println(name+"驶出停车场了");
            semaphore.release();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
